package com.gd.deron.smartrobot.baobao.recevier;

import com.gd.deron.smartrobot.baobao.MainActivity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver {

	private final String ACTION = "android.intent.action.BOOT_COMPLETED";
	private final String NOISY_ACTION = "android.media.AUDIO_BECOMING_NOISY";

	private boolean isBoot = false;
	/**
	 * 开启启动
	 * */
	@Override
	public void onReceive(Context context, Intent intent) {

		if (intent.getAction().equals(NOISY_ACTION)||intent.getAction().equals(ACTION)){
			if(!isBoot){
				isBoot = true;
				Intent intentBoot = new Intent(context, MainActivity.class);
				intentBoot.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				context.startActivity(intentBoot);
			}
		}
	}
}

